package com.learn.spring_aop.xml_config;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;

/**
 * 增强类
 */
public class AdviceCls {
    public void before() {
        System.out.println("advice-before");
    }
    
    public Object around(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
        System.out.println("advice-around-before");
        
        // 🌟🌟🌟执行目标方法并返回
        Object proceed = proceedingJoinPoint.proceed();
        
        System.out.println("advice-around-after");
        return proceed;
    }
    
    public void afterReturning() {
        System.out.println("advice-after-returning");
    }
    
    public void afterThrowing(JoinPoint joinPoint, Throwable throwable) throws Throwable {
        joinPoint.getArgs();
        joinPoint.getTarget();
        joinPoint.getStaticPart();
        
        System.out.println("advice-after-throwing-" + throwable.getMessage());
    }
    
    public void after(JoinPoint joinPoint) {
        System.out.println("advice-after");
    }
}
